package com.tedu.api.thread;
import org.junit.Test;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;


  //①
  public class LambdaHomeWork1 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 15; i++) {
                System.out.println("you want play,Let's play");
            }
        });
        t.start();
        System.out.println(t);
        Runnable b = () -> {
            for (int i = 0; i < 15; i++) {
                System.out.println("They are so dead");
            }
        };
        Thread t1=new Thread(b);
        t1.start();
    }
    //②
    @Test
    public void listAPI(){
        List<String> list = new ArrayList<>();
        list.add("走不了了");
        list.add("想玩是吧，我奉陪");
        list.add("就是这个");
        list.forEach((String)-> System.out.println("他们"+String+"\n"+"击杀"));

    }
    //③ ④
    @Test
    public void Io() throws IOException {//path.listFiles((File pathname)
        Path path = Paths.get(".");
        File fi = new File(".");
        File[] ch = fi.listFiles((File pathname)-> {String str = pathname.getName();
            System.out.println(str);
            return str.startsWith("这真是太好玩了");});

        //⑤
        FileFilter 我挚爱的杰作 = file -> file.isFile() && file.getName().toLowerCase().endsWith(".txt");
        Files.list(path).forEach(System.out::println);
    }
}